package Dungeoneering.Puzzles;

import org.powerbot.game.bot.event.MessageEvent;

import Dungeoneering.Entities.Room;

/**
 * All puzzles are derived from this.
 * @author Nicolaas
 *
 */
public abstract class PuzzleStrategy {
	
	protected enum Status { OPENING_SKILLDOOR, // = a skilldoor that doesnt have a skilling component in front of it
		OPENING_DOOR, // opening any door, being an unlocked skilldoor, or guardian door
		TRYING_SKILL_DOOR,  // trying to unlock the skill component in front of a door (like flammable debris)
		TRYING_SKILL_ROOM,  // trying to do a skilling part of the puzzle
		OTHER} // fill this crap in urself
	
	protected Status status;
	
	public PuzzleStrategy() {
		status = Status.OTHER;
	}
	
	public abstract boolean detect(Room room);
	
	
	public void solve(Room room) {
		if(!detect(room)) {
			System.out.println("Tried to solve without detecting");
			return;	
		}
		while (!isFinished(room))
			loop(room);
	}
	
	protected abstract void loop(Room room);
	
	public abstract boolean isFinished(Room room); // if puzzlestatus.finished && !detect(room)
	
	public void messageReceived(MessageEvent m) {
		// depending on the status....
	}

}
